package eo.builder;

import java.net.URL;

import eo.builder.impl.DirectoryURLVisitor;
import eo.builder.impl.JARFileURLVisitor;

/**
 * Factory class to obtain {@link URLVisitor} instances.
 * 
 * @author takeshi
 * 
 */
public final class URLVisitorFactory {

    private static URLVisitor[] visitors = { new JARFileURLVisitor(),
            new DirectoryURLVisitor() };

    /**
     * Obtain an {@link URLVisitor} for the given {@link URL}
     * 
     * @param url
     *            {@link URL}
     * @return {@link URLVisitor}
     */
    public static URLVisitor getURLVisitor(final URL url) {
        for (URLVisitor visitor : visitors) {
            if (visitor.canResolve(url)) {
                return visitor;
            }
        }
        return null;
    }
}
